#!/usr/bin/env node

const fs = require("fs-extra")
const day = require("dayjs")
const { git } = require("my-global")

const files = fs.readdirSync("./src")
const nameSet = new Set()
files.forEach((one) => {
  const name = `${day().format("MMDD")}-${one.split(".")[0]}`
  fs.ensureDirSync(`./done/${name}`)
  fs.renameSync(`./src/${one}`, `./done/${name}/${one}`)
  nameSet.add(name)
})

const main = async () => {
  const commit = [...nameSet].join(",")
  await git(`add .`)
  await git(`commit -m ${commit}`)
}

main()
